#include <stdio.h>
#include "bonc.h"
struct subject
{
	char sub_name[20];//科目姓名
	int sub_result : 31;//科目成绩
	int sub_val : 1;//科目成绩有效性
};    //第一种

/*
struct subject
{
	char sub_name[20];//科目姓名
	int sub_result : 31;//科目成绩
	int sub_val : 1;//科目成绩有效性
}s1,s2; //第二种
*/

/*
typedef struct subject
{
	char sub_name[20];//科目姓名
	int sub_result : 31;//科目成绩
	int sub_val : 1;//科目成绩有效性
}sub;  //第三种
*/
struct student
{
	char stu_name[20];//学生姓名
	char maj_name[40];//专业名称
	int maj_add;//专业地址
	int sub_num;//科目个数
	struct subject sub;//科目成绩结构体
};

int K(struct student *s,int sub_num)
{
	int index;
	float nums = 0;
	for(index = 0; index<sub_num; index++)
	{
		nums+=s[index].sub.sub_result;
	}
	nums/=sub_num;
	
	return nums;
}

int main()
{
  int nums;
	struct student s1[10]={
	{"A","网络工程",1001,10,{"语文", 80, 1}},
	{"A","网络工程",1001,10,{"数学", 80, 1}},
	{"A","网络工程",1001,10,{"外语", 80, 1}},
	{"A","网络工程",1001,10,{"体育", 80, 1}},
	{"A","网络工程",1001,10,{"政治", 99, 1}},
	{"A","网络工程",1001,10,{"历史", 80, 1}},
	{"A","网络工程",1001,10,{"化学", 80, 1}},
	{"A","网络工程",1001,10,{"物理", 80, 1}},
	{"A","网络工程",1001,10,{"生物", 80, 1}},
	{"A","网络工程",1001,10,{"地理", 80, 1}}
	};
	K(s1,10);
	bonc_print_in("avg=%d",nums);
	struct student s2[12]={
	{"B","网络工程",1002,12,{"语文", 80, 1}},
	{"B","网络工程",1002,12,{"数学", 80, 1}},
	{"B","网络工程",1002,12,{"物理", 80, 1}},
	{"B","网络工程",1002,12,{"英语", 80, 1}},
	{"B","网络工程",1002,12,{"化学", 80, 1}},
	{"B","网络工程",1002,12,{"地理", 80, 1}},
	{"B","网络工程",1002,12,{"政治", 80, 1}},
	{"B","网络工程",1002,12,{"生物", 80, 1}},
	{"B","网络工程",1002,12,{"体育", 80, 1}},
	{"B","网络工程",1002,12,{"音乐", 80, 1}},
	{"B","网络工程",1002,12,{"舞蹈", 80, 1}},
	{"B","网络工程",1002,12,{"绘画", 80, 1}}
	};
	K(s2,12);
	bonc_print_in("avg=%d",nums);
}
